public class Test {
    public String modifyString(String ss) {
        char[] s = ss.toCharArray();
        int n = s.length;
        for(int i = 0; i<n; i++) {
            if(s[i] == '?') {
                for(char ch = 'a'; ch<='z'; ch++) {
                    if((i == 0||ch!=s[i-1]) && (i==n-1 || ch!=s[i+1])) {
                        s[i] = ch;
                        break;
                    }
                }
            }
        }
        return String.valueOf(s);
    }

    public int findPoisonedDuration(int[] timeSeries, int duration) {
        int ret = 0;
        for(int i = 0; i<timeSeries.length; i++) {
            if(i+1 == timeSeries.length || duration > timeSeries[i+1] - timeSeries[i]) {
                ret += timeSeries[i+1] - timeSeries[i];
            } else {
                ret += duration;
            }
        }
        return ret;
    }
}
